/**
 * 
 */

/**
 * @author
 *
 */
public class NumBool extends Operator {
	
	//private Data s;
	/**
     * Return the number of arguments this operator takes
     */
    public int nArguments() {
	return 1;
    }

   
    
    /**
     * Evaluate this operator on the given expression
     */
    public Data evaluate(Data args[]) throws TypeException {
    	
    	if ((args[0] instanceof BooleanData)) {
    		
    		
    		
			BooleanData b = (BooleanData)args[0];
			if (b.value == true){
			 
				return new NumberData(1);
			}
			
			if (b.value == false){
				return new NumberData(0);
			}
			
			throw new TypeException(getClass().getName()
					+ ": Argument is neither a number or boolean");
		
		
    	}
	
	if(args[0] instanceof NumberData) {
	
	
	
		NumberData s = (NumberData)args[0];
		
		if (s.value <= 0){
			return new BooleanData(false);
			
		}
		
		else{return new BooleanData(true);}
		
		
	}	
    	
    	
    	
    	
    	
    	
    	

	throw new TypeException(getClass().getName()
			+ ": Argument is neither a number or boolean");
		
	
    }

    /**
     * Return a string representation of this operator
     */
    public String toString() {
	return "#";
    }

}
